package com.xiaoyu.client.ui.activity.main.mine.wallet_and_member;

import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.google.gson.Gson;
import com.xiaoyu.client.R;
import com.xiaoyu.client.model.mine.MineBean;
import com.xiaoyu.client.network.NetworkManager;
import com.xiaoyu.commonlib.network.CommonHttpResponser;
import com.xiaoyu.commonlib.ui.base.BaseActivityWithTitle;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author jx
 * @date 创建时间 2018/10/12
 * @Description 我的  -- 我的钱包
 */
public class WalletActivity extends BaseActivityWithTitle {

    private View mView;
    @BindView(R.id.wallet_money)
    TextView mWalletTxt;

    @Override
    protected void loadContentView(ViewGroup parent) {
        mView = LayoutInflater.from(this).inflate(R.layout.activity_wallet, parent, true);
        ButterKnife.bind(this);
        setTitleText("我的钱包");
    }

    @Override
    protected void onResume() {
        super.onResume();
        getMyWalletInfo();
    }

    //充值
    @OnClick(R.id.activity_wallet_top_up)
    public void topUpClick() {
        startActivity(new Intent(this, TopUpActivity.class));
    }

    //明细
    @OnClick(R.id.activity_wallet_details)
    public void detailsClick() {
        startActivity(new Intent(this, ParticularsActivity.class));
    }

    //提现
//    @OnClick(R.id.withdraw_deposit)
//    public void withdrawDepositClick(){
//        startActivity(new Intent(this,WithdrawDepositActivity.class));
//    }

    private void getMyWalletInfo() {
        NetworkManager.getMyWallet(new CommonHttpResponser() {
            @Override
            public void onSuccess(String result) {
                MineBean bean = new Gson().fromJson(result, MineBean.class);
                if (bean.getData().getMoney().equals("")) {
                    mWalletTxt.setText("0.00");
                } else {
                    mWalletTxt.setText(bean.getData().getMoney());
                }
            }

            @Override
            public void onFailed(String errorCode, String errorDiscription) {
            }
        });
    }

}
